package com.bjsxt.chapter6_proxy.dynamicProxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @ClassName StarHandler
 * @Description 处理器
 * @Author 黑马程序员
 * @Date 16:32 2024/6/21
 * @Version 1.0
 **/
public class StarHandler implements InvocationHandler {
    private Star star;

    public StarHandler(Star star) {
        this.star = star;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        Object obj = null;
        System.out.println("真正的方法执行前:");
        System.out.println("面谈、签合同、订票");


        if (method.getName().equals("sing")){
            obj = method.invoke(star,args);
        }

        System.out.println("真正的方法执行后!");
        System.out.println("收尾款");
        return obj;
    }
}
